package com.example.filecabinet.controller;

import com.example.filecabinet.entity.Device_info;
import com.example.filecabinet.service.DeviceService;
import com.example.filecabinet.util.AutoIdFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文件柜控制器
 *
 * @author wangy
 */
@RestController
public class DeviceController {
    @Autowired
    DeviceService deviceService;
    private static final Logger logger = LoggerFactory.getLogger(DeviceController.class);

    /**
     * @return
     * @Author wangy
     * @Description 新增文件柜
     * @Date 10:51 2020/3/31
     * @Param
     **/
    @RequestMapping("/addCabinet")
    @ResponseBody
    public String addCabinet(Device_info device_info) {
        //测试数据
//        Device_info device_info= new Device_info();
//        device_info.setDeviceId(AutoIdFactory.getAutoId());
//        device_info.setDeviceAddress("荆州洪湖");
//        device_info.setDeviceName("一号文件柜");
//        device_info.setDeviceCount("82");
//        device_info.setDeviceNumber("1");
//        device_info.setDeviceStatus("00");
//        device_info.setDeviceType("自助文件交换柜");
//        device_info.setEmployeeNumber("1");

        logger.info("新增一个文件柜");
        return deviceService.addCabinet(device_info);
    }

    /**
     * 修改文件柜
     *
     * @param device_info
     * @return
     */
    @RequestMapping("/updateCabinet")
    public String updateCabinet(@RequestBody Device_info device_info) {
        return deviceService.updateCabinet(device_info);
    }

    @RequestMapping("/selectCabinet")
    public String selectCabinet(@RequestBody Device_info device_info) {
        return deviceService.selectCabint(device_info);
    }
}
